{include file="public/header" /}
<body>
<form class="layui-form" id="form" action="{:url('save')}">
    <div class="x-body layui-anim" style="padding-top: 0">
        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <li class="layui-this">基本信息</li>
            </ul>
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <div class="layui-form-item">
                        <label class="layui-form-label">介绍</label>
                        <div class="layui-input-block">
                            <input type="text" name="introduce" lay-verify="required" lay-reqtext="请输入视频介绍"
                                   placeholder="请输入视频介绍" class="layui-input" value="{$info?$info.introduce:''}"/>
                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label class="layui-form-label">关联商品</label>
                        <div class="layui-input-inline">
                            <select name="product_id" id="product_id" lay-reqtext="请选择分类" lay-filter="cate">
                                <option value="{$info.product_id}" selected disabled>{$product}</option>
                            </select>
                        </div>
                    </div>

                    <div class="layui-form-item ">
                        <label class="layui-form-label">封面</label>
                        <div class="layui-input-block">
                            <div class="layui-tab-item layui-show" style="width: 260px;">
                                <img src="{$info?$info.cover:''}" class="layui-upload-img showImage" alt="上传成功后渲染" style="max-width: 100%">
                            </div>
                        </div>
                    </div>

                    <div class="layui-form-item video" >
                        <label class="layui-form-label">视频</label>
                        <div class="layui-input-inline" style="display: flex">
                            <div style="padding-left: 10px;">
                                <video src="{$info?$info.video_link_url:''}" controls style="width: 200px;" class="layui-upload-img videoLink"></video>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div>

        <input type="hidden" id="id" name="id" value="{$Request.param.id}">
        <div class="layui-form-item layui-layout-admin">
            <div class="layui-input-block">
                {if $info->getData('status') == 1}
                <div class="layui-footer" style="left: 0;">
                    <a class="layui-btn layui-btn-normal success">通过</a>
                    <a class="layui-btn layui-btn-danger fail">驳回</a>
                </div>
                {elseif $info->getData('status') == 2}
                <div class="layui-footer" style="left: 0;">
                    <a class="layui-btn">已审核通过</a>
                </div>
                {else/}
                <div class="layui-footer" style="left: 0;">
                    <a class="layui-btn">已审核驳回</a>
                </div>
                {/if}
            </div>
        </div>
    </div>
</form>
</body>
{include file="public/footer" /}
<script type="text/javascript" src="/static/admin/js/uploads.js"></script>
<script>
    $(".success").click(function () {
        layer.confirm('确定要通过吗？', {title: '请确认'}, function (index) {
            layer.msg('<div><i class="layui-icon layui-icon-loading-1 layui-anim layui-anim-rotate layui-anim-loop"></i> 加载中....', {
                shade: 0.8,
                time: 99999
            });
            execute(2)
        });
    });

    $(".fail").click(function () {
        layer.confirm('确定要驳回吗？', {title: '请确认'}, function (index) {
            layer.close(index);
            layer.prompt({title: '请填写驳回原因', formType: 2}, function (pass, index) {
                layer.close(index);
                layer.msg('<div><i class="layui-icon layui-icon-loading-1 layui-anim layui-anim-rotate layui-anim-loop"></i> 加载中....', {
                    shade: 0.8,
                    time: 99999
                });
                execute(3, pass)
            });
        });
    });

    function execute(status, reject_msg = '') {
        $.post('{:url("video/audit")}', {id: '{$info.id}', status: status, reject_msg: reject_msg}, function (data) {
            layer.closeAll();
            if (data.code == 1) {
                notify.success(data.msg, 1500, function () {
                    if (window.name != '') {
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                        parent.window.location.reload();
                    } else {
                        window.location.reload();
                    }
                });

            } else {
                notify.error(data.msg);
            }
        });
    }

</script>
</html>